package com.dd.demo01.config;

import com.dd.demo01.po.TestBean;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.BeanFactoryPostProcessor;
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
import org.springframework.beans.factory.support.RootBeanDefinition;

/**
 * @author: lkd
 * @date: 2023/04/25/9:55
 * @Description:
 */
public class BeanFactoryPostProcessorTest implements BeanFactoryPostProcessor{

	/**
	 * 主要用于注册修改BeanDefinition
	 */
	@Override
	public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException {
		DefaultListableBeanFactory defaultListableBeanFactory = (DefaultListableBeanFactory) beanFactory;
		defaultListableBeanFactory.registerBeanDefinition("testBeanDefinition", new RootBeanDefinition(TestBean.class));
		System.out.println("BeanFactoryPostProcessorTest  手动注册 BeanDefinition");
	}

}
